package com.csw.shuanfa.CodeImprove.CompleteFutureLinkedBlockingQueue.oldtest.ThreadAndBingFa.FangFaYanShi;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 1
 */
@Slf4j
public class GuessANumber extends Thread {
    private final int number;

    public GuessANumber(int number) {
        this.number = number;
    }

    @Override
    public void run() {
        int counter = 0;
        int guess = 0;
        do {
            guess = (int) (Math.random() * 100 + 1);
            log.info("" + this.getName() + " guesses " + guess);
            counter++;
        } while (guess != number);
        log.info("" + "** Correct!" + this.getName() + "in" + counter + "guesses.**");
    }
}
